<template>
  <div class="customInput">
    <div v-if="isInput" class="input">
      <div class="input-wrapper">
        <i-input
          :i-class="isError ? 'error-input' : ''"
          :type="inputType"
          :title="title"
          :placeholder="placeholder"
          :value="value === 0 || value ? value : ''"
          @change="inputChange" />
      </div>
      <div v-if="company" class="input-company">{{company}}</div>
    </div>
    <div v-if="!isInput" class="no-input">
      <div class="title">{{title}}</div>
      <div
        class="content"
        :class="{isContent: value !== '' && value !== null}"
        @tap="inputClick">{{value === '' || value === null ? placeholder : value}}</div>
      <div v-if="company" class="company">{{company}}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    isInput: {
      type: Boolean,
      default: false
    },
    inputType: {
      type: String,
      default: 'text'
    },
    title: {
      type: String,
      default: ''
    },
    value: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: ''
    },
    company: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      isError: false
    }
  },
  methods: {
    inputChange (e) {
      this.$emit('change', e)
      this.$emit('input', e.target.detail.value)
    },
    inputClick () {
      this.$emit('inputClick', this.title)
    }
  }
}
</script>


<style lang="scss" scoped>
  .customInput {
    > .input {
      width: 100%;
      display: flex;
      align-items: center;
      > .input-wrapper {
        flex: 1;
      }
      > .input-company {
        font-size: 14px;
        padding-right: 10px;
      }
    }
    > .no-input {
      height: 48.25px;
      margin-left: 15px;
      display: flex;
      align-items: center;
      font-size: 14px;
      > .title {
        min-width: 65px;
        padding-right: 10px;
        color: #495060;
      }
      > .content {
        flex: 1;
        color: rgb(219, 219, 219);
        padding-right: 15px;
        box-sizing: border-box;
        &.isContent {
          color: #495060;
        }
      }
      > .company {
        font-size: 14px;
        padding-right: 10px;
      }
    }
  }
</style>
